package com.bob.usercenter.common;

import lombok.Data;

import java.io.Serializable;

/**
 * @Author Bob
 * @Date：2024-01-24 20:55
 * @description：
 */
@Data
public class Result<T> implements Serializable {
    private Integer code;
    private String msg;
    private T data;

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static <T> Result success(T data){
        return new Result(200,"OK",data);
    }



    public static <T> Result error(ErrorCode errorCode){
        return new Result(errorCode.getCode(), errorCode.getDescription(),null);
    }
}
